#!/usr/bin/python
import sys
import os

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QSettings

from wiizard.main import MainWindow
import wiizard.globals as Global
from wiizard.requestHandler import RequestHandler
from wiizard.scrapers.gametdb import GameTdbScraper
from wiizard.cache import ImageCache as _ImageCache

if __name__ == "__main__":
  # Setup image cache
  path = os.path.dirname(QSettings("CYBERDEViL/Wiizard/", "config").fileName())
  path = os.path.join(path, "cache/")
  Global.ImageCache = _ImageCache(path)

  # Setup request handler (so that when we intergrate proxy support all
  # connections go over the proxy, also global user-agent string)
  requestHandler = RequestHandler()

  # Setup image scraper
  scraper = GameTdbScraper(requestHandler)

  app = QApplication(sys.argv)
  w = MainWindow(requestHandler, scraper)
  w.resize(600,300)
  w.setWindowTitle("Wiizard")
  w.show()
  sys.exit(app.exec_())
